/*
 * Created by SharpDevelop.
 * User: Dror B. Helper
 * Date: 01/10/2008
 * Time: 22:01
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System.Collections.Generic;
using StackOverflowClient.Messages;

namespace StackOverflowClient
{
    /// <summary>
    /// Description of MessageQueue.
    /// </summary>
    public class MessageQueue
    {
        readonly object sync = new object();

        private readonly Queue<MessageBase> queue = new Queue<MessageBase>();

        public int Count
        {
            get
            {
                lock (sync)
                {
                    return queue.Count;
                }
            }
        }

        public MessageBase Dequeue()
        {
            lock (sync)
            {
                return queue.Dequeue();
            }
        }

        public void Enqueue(MessageBase message)
        {
            lock (sync)
            {
                queue.Enqueue(message);
            }
        }

    }
}
